package cn.bone.lambda.demo01;

/**
 * Created by superbone on 2017/2/16.
 */
public class Hello {
    Runnable r1 = () -> {System.out.println(this);};
    Runnable r2 = () -> {System.out.println(toString());};

    public String toString(){
        return "hello world";
    }

    public static void main(String[] args){
        new Hello().r1.run();
        new Hello().r2.run();

        int i = 10;
        int a = i + 10;
        Location location = new Location();
        location.setLat(13.121212);
        location.setLng(42.111166);
        Runnable r = () -> {
            System.out.println(Thread.currentThread().getName()+":"+a);
            System.out.println(location);
            location.setLng(50.12);
            System.out.println(location);
        };
        new Thread(r).start();
        System.out.println(Thread.currentThread().getName());
    }
}

class Location{
    private double lng;
    private double lat;

    public double getLng() {
        return lng;
    }

    public void setLng(double lng) {
        this.lng = lng;
    }

    public double getLat() {
        return lat;
    }

    public void setLat(double lat) {
        this.lat = lat;
    }

    @Override
    public String toString() {
        return "Location:{lng:"+lng+",lat:"+lat+"}";
    }
}
